Skip to content

fix(search): display every value of an array text field per language - #824

Merged
ddeboer merged 1 commit into
mainfrom
worktree-array-text-display
Sep 4, 2026
Merged

fix(search): display every value of an array text field per language#824
ddeboer merged 1 commit into
mainfrom
worktree-array-text-display

Conversation

@ddeboer

@ddeboer ddeboer commented Sep 4, 2026

Copy link
Copy Markdown
Member

Fix #817

A text field declared array: true indexed every value – applyText folds all of a locale’s values into the _search_<locale> companion – but displayed one: the output branch kept the first value per language, and the Typesense collection definition typed the display pattern string regardless of array. A person with three untagged alternate names was found by any of them and showed only the first.

Change

array now decides the display shape for text as the docs already say it does for every kind:

  • Projection (@lde/search): an array text field stores every value of a language as a list, deduped per language like a keyword array; a single-valued field keeps the first value, unchanged. An empty literal is dropped either way.
  • Collection definition (@lde/search-typesense): the display pattern is typed string[] for an array text field, root and nested, through the same value-type rule the other kinds use.
  • Reconstruction: localizedValue reads a string or a list, so hits and both label paths carry every value.
  • Docs: the array JSDoc, the array paragraph in the search reference and the collection-definition notes say what array means for localized text.

API output

Unchanged in shape. Every text field is already [LanguageString!] in GraphQL and a language-to-list map in LocalizedValue, because a field can carry several languages. A consumer of an array text field sees more entries in the same list; a non-array text field returns exactly what it did.

Rebuilds

Blue/green rebuilds create a fresh collection and pick up the new type. In-place rebuilds keep the existing collection, whose display pattern is still typed string: verified against Typesense 30.2 that a list imports into an index: false regex field regardless of its declared type, so no drift check is needed. A deployment with array text fields reindexes those collections to show every value.

- The projection kept the first value per language on display while
  folding every value into the search companion, so a multi-valued text
  field was found by any value and showed only one
- Store every value of a language as a list for an array text field,
  deduped per language as a keyword array is; a single-valued field
  keeps the first value; an empty literal is dropped either way
- Type the display pattern as a list for an array text field in the
  Typesense collection definition, root and nested, through the one
  value-type rule the other kinds already use
- Read a string or a list back when reconstructing localized text, so
  hits and both label paths carry every value
- State what array means for localized text in the field JSDoc and the
  docs
@ddeboer
ddeboer force-pushed the worktree-array-text-display branch from db5e4f1 to 8c3abbb Compare September 4, 2026 11:45
@ddeboer
ddeboer merged commit 61d1916 into main Sep 4, 2026
4 checks passed
@ddeboer
ddeboer deleted the worktree-array-text-display branch September 4, 2026 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

search: a multi-valued text field displays only its first value per language

1 participant